package grape.auth.service.clientdetails.api;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import grape.auth.service.clientdetails.po.OauthClientDetails;
import grape.common.service.common.IBaseService;

/**
 * <p>
 * 服务客户端表 服务类
 * </p>
 *
 * @author yangwei
 * @since 2020-03-31
 */
public interface IOauthClientDetailsService extends IBaseService<OauthClientDetails> {
    /**
     * 判断clientId是否已存在
     * @param clientId
     * @return
     */
    default boolean existClientId(String clientId){
        assertParamNotEmpty(clientId,"clientId 不能为空");
        OauthClientDetails po = new OauthClientDetails();
        po.setClientId(clientId);
        int r = count(Wrappers.query(po));
        return r > 0;
    }
    default OauthClientDetails getByClientId(String clientId){
        assertParamNotEmpty(clientId,"clientId 不能为空");
        OauthClientDetails po = new OauthClientDetails();
        po.setClientId(clientId);
        return getOne(po);
    }
}
